<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>Cadastro de Professores</title>
    </h:head>
    <h:body>
        <ui:include src="../util/menu.xhtml"/>            
        <h:form id="display">
            <br/>
            <p:confirmDialog global="true">
                <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" 
                    icon="ui-icon-check"/>
                <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" 
                    icon="ui-icon-close"/>
            </p:confirmDialog>                    

            <p:messages autoUpdate="true" id="MSG"/>
            
            <h:inputHidden value="#{controllerProfessores.id}"/>
            
            <p:panelGrid columns="2" id="form" style="padding: 5px">
                <f:facet name="header">
                    Cadastro de Professores
                </f:facet>
                
                <h:outputText value=""/>
                <h:outputText value="#{controllerProfessores.status}"/>
                
                <h:outputText value="ID"/>
                <p:inputText value="#{controllerProfessores.id}" required="true" readonly="true" disabled="true"/>
                
                <h:outputText value="Nome"/>
                <p:inputText value="#{controllerProfessores.nome}" required="true" requiredMessage="Nome do Professor é Obrigatório"  autocomplete="false"/>
                
                <h:outputText value="Login"/>
                <p:inputText value="#{controllerProfessores.login}" required="true" requiredMessage="Login do Professor é Obrigatório"  autocomplete="false" disabled="#{controllerProfessores.desabilita}"/>
                
                <h:outputText value="Senha"/>
                <p:password value="#{controllerProfessores.senha}" required="true" requiredMessage="Senha do Professor é Obrigatório" autocomplete="off"/>
                
                <f:facet name="footer">
                    <p:commandButton value="Novo" actionListener="#{controllerProfessores.novo()}" update="display" process="@this"/>
                    <p:commandButton value="Salvar" actionListener="#{controllerProfessores.gravar()}" update=":form2,display"/>
                </f:facet>               
            </p:panelGrid>    
            <p:separator />                   
        </h:form>
        
        <h:form id="form2">
            <p:dataTable var="professores" value="#{controllerProfessores.professores}"
                         paginator="true"
                         rows="9"
                         id="tabela">
                <f:facet name="header">
                    Professores Cadastrados
                </f:facet>
                <p:column headerText="Nome">
                    <h:outputText value="#{professores.nome}"/>
                </p:column>
                <p:column headerText="Login">
                    <h:outputText value="#{professores.usuario}"/>
                </p:column>

                <p:column headerText="Ações">
                    <p:commandButton value="Excluir" action="#{controllerProfessores.excluir(professores.id)}" update=":form2">
                        <p:confirm header="?" message="Deseja Excluir?" icon="ui-icon-alert" />
                    </p:commandButton>
                    <p:commandButton value="Alterar" action="#{controllerProfessores.atualizar(professores.id)}" update=":display"/>
                </p:column>
                
                                              
            </p:dataTable>
            
        </h:form>
    </h:body>
</html>

